package b1.scenes.home
{
	import b1.controls.basic.BasicMc;
	import b1.net.ResourceHelper;
	import b1.utils.*;
	
	import flash.display.Sprite;

	public class HomeBackground extends Sprite
	{
		public function HomeBackground(homeIndex:int)
		{
			super();
			var HomeBgr:Class;
			var homeBgr:Sprite;
			//龙的家和鸟的家
			if (homeIndex == 0 || homeIndex == 1)
			{
				//背景层
				HomeBgr = ResourceHelper.getInstance().getClassByName("Home" + homeIndex.toString());
				homeBgr = new HomeBgr();
				homeBgr.y = BFont.stageHeight - homeBgr.height;
				addChild(homeBgr);
				//树
				var Tree1:Class = ResourceHelper.getInstance().getClassByName("Tree1");
				var tree1:BasicMc = new BasicMc(Tree1, 5);
				addChild(tree1);
				
				var tree2:BasicMc = new BasicMc(Tree1, 4);
				tree2.height = 70;
				tree2.scaleX = -tree2.scaleY;
				addChild(tree2);
				
				var tree3:BasicMc = new BasicMc(Tree1, 3);
				tree3.height = 60;
				tree3.scaleX = tree3.scaleY;
				addChild(tree3);
				
				var tree4:BasicMc = new BasicMc(Tree1, 6);
				tree4.height = 80;
				tree4.scaleX = -tree4.scaleY;
				addChild(tree4);
				
				if (homeIndex == 0)
				{
					tree1.x = 366;
					tree1.y = 133;
					
					tree2.x = 484;
					tree2.y = 198;
					
					tree3.x = 578;
					tree3.y = 208;
					
					tree4.x = 735;
					tree4.y = 182;
				}
				else
				{
					tree1.x = 455;
					tree1.y = 148;
	
					tree2.x = 500;
					tree2.y = 215;
	
					tree3.x = 198;
					tree3.y = 185;
					
					tree4.x = 318;
					tree4.y = 169;
	
				}
			}
			//墓地
			else if (homeIndex == 2)
			{
				//背景层
				HomeBgr = ResourceHelper.getInstance().getClassByName("Home" + homeIndex.toString());
				homeBgr = new HomeBgr();
				homeBgr.y = BFont.stageHeight - homeBgr.height;
				addChild(homeBgr);
				var BlackTree0:Class = ResourceHelper.getInstance().getClassByName("BlackTree0");
				var blackTree0:BasicMc = new BasicMc(BlackTree0, 30);
				blackTree0.x = 0;
				blackTree0.y = 40;
				var BlackTree1:Class = ResourceHelper.getInstance().getClassByName("BlackTree1");
				var blackTree1:BasicMc = new BasicMc(BlackTree1, 30);
				blackTree1.x = 0;
				blackTree1.y = 110;
				addChild(blackTree1);
				addChild(blackTree0);
				var BlackTree2:Class = ResourceHelper.getInstance().getClassByName("BlackTree2");
				var blackTree2:BasicMc = new BasicMc(BlackTree2, 30);
				blackTree2.x = 0;
				blackTree2.y = 50;
				addChild(blackTree2);
				var blackTree3:BasicMc = new BasicMc(BlackTree1, 20);
				blackTree3.alpha = 0.8;
				blackTree3.x = 375;
				blackTree3.y = 320;
				blackTree3.height = 80;
				blackTree3.width = 100;
				blackTree3.rotation = -20;
				addChild(blackTree3);
				addChild(blackTree0);
				var GhostFire:Class = ResourceHelper.getInstance().getClassByName("GhostFire");
				var ghostFire0:BasicMc = new BasicMc(GhostFire, 10);
				ghostFire0.width = 30;
				ghostFire0.scaleY = ghostFire0.scaleX;
				ghostFire0.x = 140;
				ghostFire0.y = 480;
				addChild(ghostFire0);
			}
			//西郊
			else if (homeIndex == 3)
			{
				//背景层
				HomeBgr = ResourceHelper.getInstance().getClassByName("Home" + homeIndex.toString());
				homeBgr = new HomeBgr();
				homeBgr.y = BFont.stageHeight - homeBgr.height;
				addChild(homeBgr);
				var Home3Tree1:Class = ResourceHelper.getInstance().getClassByName("Home3Tree1");
				var home3Tree1:BasicMc = new BasicMc(Home3Tree1, 20);
				home3Tree1.x = 54;
				home3Tree1.y = 419;
				addChild(home3Tree1);
				var Home3Bgr2:Class = ResourceHelper.getInstance().getClassByName("Home3Bgr2");
				var home3Bgr2:Sprite = new Home3Bgr2();
				addChild(home3Bgr2);
			}
			//选人界面
			else if (homeIndex == 4)
			{
				//背景层
				HomeBgr = ResourceHelper.getInstance().getClassByName("Home" + homeIndex.toString());
				homeBgr = new HomeBgr();
				homeBgr.y = BFont.stageHeight - homeBgr.height;
				addChild(homeBgr);
				var Home5Tree1:Class = ResourceHelper.getInstance().getClassByName("Home5Tree1");
				var home5Tree1:BasicMc = new BasicMc(Home5Tree1, 20);
				home5Tree1.x = 440;
				home5Tree1.y = 0;
				addChild(home5Tree1);
				var Home5Grass1:Class = ResourceHelper.getInstance().getClassByName("Grass1");
				var home5Grass1:BasicMc = new BasicMc(Home5Grass1, 20);
				home5Grass1.x = 730;
				home5Grass1.y = 500;
				addChild(home5Grass1);
				var Home5Grass2:Class = ResourceHelper.getInstance().getClassByName("Grass2");
				var home5Grass2:BasicMc = new BasicMc(Home5Grass2, 20);
				home5Grass2.x = 540;
				home5Grass2.y = 515;
				addChild(home5Grass2);
			}
			//爱伦爵士府（家背景/战斗背景）
			else if (homeIndex == 5 || homeIndex == 6)
			{
				//背景层
				HomeBgr = ResourceHelper.getInstance().getClassByName("Home5");
				homeBgr = new HomeBgr();
				homeBgr.y = BFont.stageHeight - homeBgr.height;
				addChild(homeBgr);
				var Fire1:Class = ResourceHelper.getInstance().getClassByName("Fire1");
				var fire1:BasicMc = new BasicMc(Fire1);
				fire1.x = 350;
				fire1.y = 200;
				addChild(fire1);
				var Lamp1:Class = ResourceHelper.getInstance().getClassByName("Lamp1");
				var lamp1:BasicMc = new BasicMc(Lamp1);
				lamp1.x = 171;
				lamp1.y = 100;
				addChild(lamp1);
				var lamp2:BasicMc = new BasicMc(Lamp1);
				lamp2.x = 574;
				lamp2.y = 98;
				addChild(lamp2);
				if (homeIndex == 5)
				{
					var Sofa1:Class = ResourceHelper.getInstance().getClassByName("Sofa1");
					var sofa1:Sprite = new Sofa1();
					sofa1.x = 210;
					sofa1.y = 350;
					addChild(sofa1);
					var sofa2:Sprite = new Sofa1();
					sofa2.scaleX = -1
					sofa2.x = 600;
					sofa2.y = 350;
					addChild(sofa2);
					var Desk1:Class = ResourceHelper.getInstance().getClassByName("Desk1");
					var desk1:Sprite = new Desk1();
					desk1.x = 314;
					desk1.y = 415;
					addChild(desk1);
					var Candle1:Class = ResourceHelper.getInstance().getClassByName("Candle1");
					var candle1:BasicMc = new BasicMc(Candle1);
					candle1.x = 366;
					candle1.y = 363;
					addChild(candle1);
				}
			}
			else if (homeIndex == 7)
			{
				//背景层
				HomeBgr = ResourceHelper.getInstance().getClassByName("Home" + homeIndex.toString());
				homeBgr = new HomeBgr();
				addChild(homeBgr);
			}
			else if (homeIndex == 8)
			{
				HomeBgr = ResourceHelper.getInstance().getClassByName("Home8");
				homeBgr = new HomeBgr();
				homeBgr.y = BFont.stageHeight - homeBgr.height;
				addChild(homeBgr);
			}
		}
		
	}
}